-- util.lua

function FindPlayer(str)
	if not str then return end
	
	str = string.lower(str)

	-- Find by UniqueID
	for k, v in pairs(player.GetAll()) do
		if tonumber(str) == v:UniqueID() then
			return v
		end
	end
	
	-- Find by UserID
	for k, v in pairs(player.GetAll()) do
		if tonumber(str) == v:UserID() then
			return v
		end
	end
	
	-- Find by Steam ID
	for k, v in pairs(player.GetAll()) do
		if string.lower( v:SteamID() ) == str then
			return v
		end
	end
	
	return nil
end



legalChars = { " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }
function IsRPNameLegal(name, legalChars)
	local matches = 0
	name = string.lower(name)
	for i = 1, #name do
		for j = 1, #legalChars do
			if string.sub(name, i, i) == legalChars[j] then
				matches = matches + 1
				break
			end
		end
	end
	if matches == #name then
		return true
	else
		return false
	end
end